package panda.rmi.server.impl;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.List;

import panda.query.struct.Attribute;
import panda.record.Schema;
import panda.rmi.server.ServerMetaData;

public class PandaServerMetaData extends UnicastRemoteObject implements ServerMetaData {

	private Schema sch;
	private List<Attribute> fields = new ArrayList<Attribute>();
	
	protected PandaServerMetaData(Schema sch) throws RemoteException {
		super();
		fields.addAll(sch.getAllAttributes());
	}

	@Override
	public int getColumnCount() throws RemoteException {
		return fields.size();
	}

	@Override
	public String getColumnName(int idx) throws RemoteException {
		return fields.get(idx).getAttributeName();
	}

	@Override
	public int getColumnType(int idx) throws RemoteException {
		return sch.getType(fields.get(idx).getAttributeName());
	}

}
